<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Model\PersonalPageTemplateUser
 *
 * @property int $id
 * @property int $user_id 用户id
 * @property int $template_id 模板id
 * @property string|null $cover 封面
 * @property string $title 模板名称
 * @property string $content 内容
 * @property int $is_default 是否默认1默认0 不是默认
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property int $popularity 人气
 * @property int|null $cate category->id
 * @property string $components 自定义组件
 * @property int $type 1定制模板2自定义模板
 * @property string $background 背景颜色
 * @property int $is_clone 是否允许被克隆
 * @property float $clone_price 克隆价格
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Model\UserInterPushRecordMaterial[] $interPushRecordMaterial
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereBackground($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereCate($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereClonePrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereComponents($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereCover($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereIsClone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereIsDefault($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser wherePopularity($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereTemplateId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereUserId($value)
 * @mixin \Eloquent
 * @property-read \App\Model\UserInterPushInfo $interPushInfo
 * @property int $share 分享量
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\PersonalPageTemplateUser whereShare($value)
 */
class PersonalPageTemplateUser extends Model
{
    protected $table = "personal_page_template_user";


    /**
     * 获取个人网页互推匹配记录
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany
     */
    public function interPushRecordMaterial()
    {
        return $this->morphMany(UserInterPushRecordMaterial::class, "interPushRecordMaterials","source_type","source_id","id");
    }

    /**
     * 文章对应素材
     * @return \Illuminate\Database\Eloquent\Relations\MorphToMany
     */
    public function interPushInfo()
    {
        return $this->morphedByMany(UserInterPushInfo::class,"material","material_type","material_id","id");
    }

}
